 /*
 Copyright (C) 2024 HiHope Open Source Organization .
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

#ifndef MQTT_TASK_H
#define MQTT_TASK_H

#if 1
  //华为云设备接入【标准版】对接地址或URL
    #define HOST_ADDR       "117.78.5.125"
  //#define HOST_ADDR       "02c20f4b60.st1.iotda-device.cn-north-4.myhuaweicloud.com"
    #define HOST_PORT       1883

    #define DEVICE_ID       "683f8ea432771f177b3e858a_ws63a"
    #define MQTT_USERNAME   "683f8ea432771f177b3e858a_ws63a"
    #define MQTT_CLIENT_ID  "683f8ea432771f177b3e858a_ws63a_0_0_2025060400"
    #define MQTT_PASSWORD   "c62e04e6dddb1c6d3becd84af8a0b0cfb7373b9b922d21eaf07a7f3b4a97b3f0"
    #define SERVICE_NAME    "hdc2025_demos"
#endif


#define PUBLISH_TOPIC       "$oc/devices/"DEVICE_ID"/sys/properties/report"
#define SUBCRIB_TOPIC       "$oc/devices/"DEVICE_ID"/sys/commands/#"
#define RESPONSE_TOPIC      "$oc/devices/"DEVICE_ID"/sys/commands/response"
#define RESPONSE_DBG        (1)
#define PAYLOAD_BUFF_LEN    (128)

#include "iot_gpio.h"
#define BEEP_ON_OFF_CTRL_GPIO     (11)   //A11 
#define DOOR_ON_OFF_CTRL_GPIO     (9)    //A9
#define FAN_ON_OFF_CTRL_GPIO      (3)    //D1
#define LIGHT_ON_OFF_CTRL_GPIO    (2)    //D2


void MqttTaskInit(void);
int MqttTaskConnect(const char *host, unsigned short port,
                    const char *clientId, const char *username, const char *password);
int MqttTaskSubscribe(char *topic);
int MqttTaskPublish(char *topic, char *payload);
int MqttTaskUnSubscribe(char *topic);
int MqttTaskDisconnect(void);
void MqttTaskDeinit(void);

int mqttMutexLock(Mutex* m);
int mqttMutexUnlock(Mutex* m);
#endif
